<template>
  <div class="plan-card">
    <div class="plan-header">
      <span class="plan-title">任务计划</span>
      <span class="plan-status">{{ getStatusText() }}</span>
    </div>
    
    <div class="plan-content">
      <div 
        v-for="(task, index) in tasks" 
        :key="task.id"
        class="task-item"
      >
        <span class="task-status" :class="task.status">
          {{ getStatusIcon(task.status) }}
        </span>
        <span class="task-text" :class="{ completed: task.status === 'completed' }">{{ task.content }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'

const props = defineProps({
  planData: {
    type: Object,
    required: true
  }
})

const tasks = computed(() => {
  return props.planData?.plan || []
})

const getStatusText = () => {
  const completed = tasks.value.filter(t => t.status === 'completed').length
  const total = tasks.value.length
  return `${completed}/${total}`
}

const getStatusIcon = (status) => {
  const icons = {
    'completed': '✓',
    'in_progress': '▶',
    'cancelled': '✕',
    'pending': '○'
  }
  return icons[status] || '○'
}
</script>

<style scoped>
.plan-card {
  border: 1px solid var(--el-border-color);
  border-radius: 6px;
  padding: 12px;
  margin: 8px 0;
  background: var(--el-fill-color-blank);
}

.plan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--el-border-color-lighter);
}

.plan-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--el-text-color-primary);
}

.plan-status {
  font-size: 12px;
  color: var(--el-text-color-secondary);
}

.plan-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}

.task-status {
  width: 16px;
  flex-shrink: 0;
  font-size: 12px;
  text-align: center;
  color: var(--el-text-color-secondary);
}

.task-status.completed {
  color: var(--el-color-success);
}

.task-status.in_progress {
  color: var(--el-color-primary);
}

.task-status.cancelled {
  color: var(--el-color-danger);
}

.task-text {
  color: var(--el-text-color-primary);
  line-height: 1.4;
}

.task-text.completed {
  color: var(--el-text-color-secondary);
  text-decoration: line-through;
}
</style>
